package com.manage.project.biz.controller;

import java.util.List;

import com.manage.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.manage.framework.aspectj.lang.annotation.Log;
import com.manage.framework.aspectj.lang.enums.BusinessType;
import com.manage.project.biz.domain.BizQitasheshizhuanxiangjiancha;
import com.manage.project.biz.service.IBizQitasheshizhuanxiangjianchaService;
import com.manage.framework.web.controller.BaseController;
import com.manage.framework.web.domain.AjaxResult;
import com.manage.common.utils.poi.ExcelUtil;
import com.manage.framework.web.page.TableDataInfo;

/**
 Controller
 *
 * @author liutao
 *
 */
@RestController
@RequestMapping("/biz/qitasheshizhuanxiangjiancha")
public class BizQitasheshizhuanxiangjianchaController extends BaseController
{
    @Autowired
    private IBizQitasheshizhuanxiangjianchaService bizQitasheshizhuanxiangjianchaService;

    /**
     * 查询其他设施专项检查列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:qitasheshizhuanxiangjiancha:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizQitasheshizhuanxiangjiancha bizQitasheshizhuanxiangjiancha)
    {
        startPage();
        List<BizQitasheshizhuanxiangjiancha> list = bizQitasheshizhuanxiangjianchaService.selectBizQitasheshizhuanxiangjianchaList(bizQitasheshizhuanxiangjiancha);
        return getDataTable(list);
    }

    /**
     * 导出其他设施专项检查列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:qitasheshizhuanxiangjiancha:export')")
    @Log(title = "其他设施专项检查", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizQitasheshizhuanxiangjiancha bizQitasheshizhuanxiangjiancha)
    {
        List<BizQitasheshizhuanxiangjiancha> list = bizQitasheshizhuanxiangjianchaService.selectBizQitasheshizhuanxiangjianchaList(bizQitasheshizhuanxiangjiancha);
        ExcelUtil<BizQitasheshizhuanxiangjiancha> util = new ExcelUtil<BizQitasheshizhuanxiangjiancha>(BizQitasheshizhuanxiangjiancha.class);
        return util.exportExcel(list, "其他设施专项检查数据");
    }

    /**
     * 获取其他设施专项检查详细信息
     */
//    @PreAuthorize("@ss.hasPermi('biz:qitasheshizhuanxiangjiancha:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizQitasheshizhuanxiangjianchaService.selectBizQitasheshizhuanxiangjianchaById(id));
    }

    /**
     * 新增其他设施专项检查
     */
//    @PreAuthorize("@ss.hasPermi('biz:qitasheshizhuanxiangjiancha:add')")
    @Log(title = "其他设施专项检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizQitasheshizhuanxiangjiancha bizQitasheshizhuanxiangjiancha)
    {
        BizQitasheshizhuanxiangjiancha bizQitasheshizhuanxiangjiancha2 = new BizQitasheshizhuanxiangjiancha();
        List<BizQitasheshizhuanxiangjiancha> list = bizQitasheshizhuanxiangjianchaService.selectBizQitasheshizhuanxiangjianchaList(bizQitasheshizhuanxiangjiancha2);
        if(list.size()>0){
            bizQitasheshizhuanxiangjiancha.setField4(DateUtils.dateTime(list.get(0).getCreateTime()));
        }
//        bizQitasheshizhuanxiangjiancha.setField6(DateUtils.getDate());
//        bizQitasheshizhuanxiangjiancha.setField8("60");
//        bizQitasheshizhuanxiangjiancha.setField9("2");
        return toAjax(bizQitasheshizhuanxiangjianchaService.insertBizQitasheshizhuanxiangjiancha(bizQitasheshizhuanxiangjiancha));
    }

    /**
     * 修改其他设施专项检查
     */
    @Log(title = "其他设施专项检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizQitasheshizhuanxiangjiancha bizQitasheshizhuanxiangjiancha)
    {
        return toAjax(bizQitasheshizhuanxiangjianchaService.updateBizQitasheshizhuanxiangjiancha(bizQitasheshizhuanxiangjiancha));
    }

    /**
     * 删除其他设施专项检查
     */
//    @PreAuthorize("@ss.hasPermi('biz:qitasheshizhuanxiangjiancha:remove')")
    @Log(title = "其他设施专项检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizQitasheshizhuanxiangjianchaService.deleteBizQitasheshizhuanxiangjianchaByIds(ids));
    }
}
